<?php 

$datastore = Context::getObject('volatileDataStore');
$datastore->addObject('ciccio', 'pluto');
$datastore->addObject('radioTest', 'Wolf');

$headingText = new Heading('Pollo');
$button = new Button('Touch me', 'test');
$header = new Header($headingText);
$header->setRightButton($button);

$controlGroup = new ControlGroup();
$controlGroup->setGroupDirection(Direction::$groupHorizontal);

$button1 = new Button('Remove', 'remove');
$button1->addAttribute(new Icon(Icon::$delete));
$button2 = new Button('Add', 'remove');
$button2->addAttribute(new Icon(Icon::$plus));
$button3 = new Button('Up', 'remove');
$button3->addAttribute(new Icon(Icon::$arrowUp));
$button4 = new Button('Down', 'remove');
$button4->addAttribute(new Icon(Icon::$arrowDown));
$controlGroup->addElement($button1);
$controlGroup->addElement($button2);
$controlGroup->addElement($button3);
$controlGroup->addElement($button4);

$footer = new Footer();
$footer->addAttribute(new Attribute('class', 'ui-bar'));
$footer->addElement($controlGroup);

$textField = new TextField('ciccio', 'Nome:');
$textField->setDataStore($datastore);
$textField->setInlineLabel(Label::$labelInline);
//$textField->setLabelVisibility(Label::$labelHidden);

$checkbox = new Checkbox('checkboxes', 'Is this a single checkbox?');
$checkbox->addElement('singleCheckbox', 'Am I one?');
$checkbox->addElement('anotherCheckbox', 'Am I two?');
$checkbox->setDefaultValue('singleCheckbox');
//$checkbox->setGroupDirection(Direction::$groupHorizontal);
//$checkbox->setLabelVisibility(Label::$labelHidden);
//$checkbox->setInlineLabel(Label::$labelInline);

$radio = new RadioButton('radiogaga', 'All we hear is:');
$radio->addElement('gaga', 'Radio Gaga');
$radio->addElement('gugu', 'Radio Gugu');
$radio->setDefaultValue('gugu');
//$radio->setGroupDirection(Direction::$groupHorizontal);
//$radio->setLabelVisibility(Label::$labelHidden);
//$radio->setInlineLabel(Label::$labelInline);

$select = new Select('newSelect', 'Why not a select?');
$select->addOption('option1');
$select->addOption('option2');
$select->addOption('asdf');
$select->setDefaultValue('option2');
//$select->setInlineLabel(Label::$labelInline);
//$select->setLabelVisibility(Label::$labelHidden);

$moreSelect1 = new Select('moreSelect', 'Why not two then!');
$moreSelect1->addOption('Argh!?');
$moreSelect1->addOption('Argh!?2');
$moreSelect1->addOption('Argh!?0');

$moreSelect2 = new Select('moreSelect', 'Why not two then!');
$moreSelect2->addOption('Argh!?');
$moreSelect2->addOption('Argh!?2');
$moreSelect2->addOption('Argh!?0');

$selectFS = new FieldSet('Why not two of them');
$selectFS->addElement($moreSelect1);
$selectFS->addElement($moreSelect2);
//$selectFS->setInlineLabel(Label::$labelInline);
//$selectFS->setLabelVisibility(Label::$labelHidden);
//$selectFS->setGroupDirection(Direction::$groupHorizontal);

$slider = new Slider('sliderTest', 'How much do you love slide guitar?', 0, 100);
$slider->setInlineLabel(Label::$labelInline);
$slider->setDefaultValue(50);
//$slider->setLabelVisibility(Label::$labelHidden);

$flip = new FlipToggle('flipTest', 'Flip me!');
$flip->setInlineLabel(Label::$labelInline);
$flip->setDefaultValue('on');
$flip->setDataTheme(new DataTheme(DataTheme::$b));

$textarea = new TextArea('area51', 'You are the Shakespeare of informatics!');
$textarea->setInlineLabel(Label::$labelInline);

$form = new Form('testForm');
$form->setDataTheme(new DataTheme(DataTheme::$e));
$form->addElement($textField);
$form->addElement($checkbox);
$form->addElement($radio);
$form->addElement($select);
$form->addElement($selectFS);
$form->addElement($slider);
$form->addElement($flip);
$form->addElement($textarea);

$grid = new Grid('testGrid', GridColumns::$fiveColumn);
$grid->addElement(new Paragraph(NULL, 'ciao'));
$grid->addElement(new Paragraph(NULL, 'ciao'));
$grid->addElement(new Paragraph(NULL, 'ciao'));
$grid->addElement(new Paragraph(NULL, 'ciao'));
$grid->addElement(new Paragraph(NULL, 'ciao'));
$grid->addElement(new Paragraph(NULL, 'ciao'));
$grid->addElement(new Paragraph(NULL, 'ciao'));

$collapsibleBlock = new CollapsibleBlock('testCollapsibleBlock', new Heading('Testing collapsibles'));
$collapsibleBlock->addElement(new Paragraph(NULL, 'Oh, hi! I did not expect you to open me so soon!'));
$collapsibleBlock->setDataTheme(new DataTheme(DataTheme::$a));
$collapsibleBlock->setContentDataTheme(new DataTheme(DataTheme::$c));
$collapsibleBlock->setCollapsed(FALSE);

$collapsibleBlock1 = new CollapsibleBlock('testCollapsibleBlock1', new Heading('Testing collapsibles'));
$collapsibleBlock1->addElement(new Paragraph(NULL, 'Oh, hi! I did not expect you to open me so soon!'));
$collapsibleBlock2 = new CollapsibleBlock('testCollapsibleBlock2', new Heading('Testing collapsibles'));
$collapsibleBlock2->addElement(new Paragraph(NULL, 'Oh, hi! I did not expect you to open me so soon!'));
$collapsibleBlock3 = new CollapsibleBlock('testCollapsibleBlock3', new Heading('Testing collapsibles'));
$collapsibleBlock3->addElement(new Paragraph(NULL, 'Oh, hi! I did not expect you to open me so soon!'));
$collapsibleSet = new CollapsibleSet('collaset');
$collapsibleSet->addElement($collapsibleBlock1);
$collapsibleSet->addElement($collapsibleBlock2);
$collapsibleSet->addElement($collapsibleBlock3);

$list = new ListView('testList');
$listItem = new ListItem();
$listItem->addElement(new Button('asdf', '#'));
$list->addElement($listItem);
$listItem = new ListItem();
$list->addElement($listItem);
$listItem->addElement(new Button('asdf', '#'));
$listItem = new ListItem();
$list->addElement($listItem);
$listItem->addElement(new Button('asdf', '#'));

$page = new Page('myPage');
$page->setDataTheme(new DataTheme(DataTheme::$d));
$page->addElement($header);
$page->addElement($footer);
$page->addElement($collapsibleSet);
$page->addElement($grid);
$page->addElement($collapsibleBlock);
$page->addElement($form);
$page->addElement($list);

?>

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>

<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 

 -->
 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script type="text/javascript" src="files/vendor/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="files/vendor/jquery/jquery.mobile-1.0.min.js"></script>
</head>
<body>
<?php
	$page->render();
?>
</body>
</html>
